home *** CD-ROM | disk | FTP | other *** search
/ Imagine the Universe (9th Edition) / Imagine the Universe 9 - Disc 1.iso / pc / imagine / docs / science / quiz_l2 / js / calorimeters.js < prev    next >
Text File  |  2002-12-30  |  2KB  |  63 lines

  1. // Path needs to be relative link from page that called this script
  2. Image1 = new Image();
  3. Image1.src = "../../../Images/heasarc/icons/blank2.gif";
  4. Image2 = new Image();
  5. Image2.src = "../../../Images/heasarc/icons/star2.gif";
  6.  
  7. total = 4;
  8. yourAnswer = new Array(total);
  9. answer = new Array("C","A","B","C");
  10.  
  11. function Swap(start, end) {
  12.     for (i = start; i <= end; i++) {
  13.         document.images["correct" + i].src = Image2.src;
  14.     }
  15.     return true;
  16. }
  17.  
  18. function AssignClick(letter, position) {
  19.     yourAnswer[position] = letter.value;
  20. }
  21.  
  22. function CheckMe() {
  23.  
  24. var count = 0;
  25.  
  26.     for (i = 0; i < total; i++) {
  27.         if (yourAnswer[i] == answer[i]) {count++;}
  28.     }
  29.  
  30.     Swap(1, total);
  31.  
  32.     var win = window.open("", "score_window", "width=300,height=300, resizable=yes,scrollbars=yes");
  33.  
  34.  
  35.     win.document.write('<HTML>\n<HEAD>\n<TITLE>Your Score</TITLE>\n</HEAD>\n');
  36.     win.document.write('<BODY BGCOLOR="#FFFFFF" TEXT="#000094" LINK="#7D5F00"');            win.document.write(' VLINK="#9E0A42" ALINK="#FF0000">');
  37.     win.document.write('<H2 ALIGN="CENTER">');
  38.  
  39.     if (count == total) {
  40.         win.document.write('<P ALIGN="CENTER">\n');
  41.         win.document.write('<IMG SRC="../../../Images/icons/fireworks.gif" BORDER=0>\n');
  42.         win.document.write('</P>\n');
  43.     }
  44.     win.document.write ("Your score is " + 
  45.         Math.round(count*100/total) + " %!\n</H2>\n</P><P>\n");
  46.  
  47.     win.document.write("<CENTER>")
  48.     win.document.write("<FORM>");
  49.     win.document.write("<TABLE BORDER=5 CELLPADDING=10>");
  50.     win.document.write("<TR><TD ALIGN=\"CENTER\">");
  51.     win.document.write("<INPUT TYPE=button VALUE=\"Close\" onClick=\"window.close()\"></TD></TR>");
  52.     win.document.write("</TABLE>");
  53.     win.document.write("</FORM>");
  54.     win.document.write("</CENTER>");
  55.     if (count < total) {
  56.         win.document.write ("<CENTER>\n</P><P><P><BR><BR><BR>\n");
  57.         win.document.write ("Stars are next to the correct answers.</P><P>\n");
  58.         win.document.write ("</CENTER>\n");
  59.     }
  60.  
  61.     win.document.write('</BODY>\n</HTML>\n');
  62. }
  63.